package com.subfg.payment.config;


import com.subfg.common.entity.config.pay.ConfigPayAliModel;
import com.subfg.payment.entity.common.SystemPaymentModel;
import com.subfg.payment.server.PaymentServer;
import com.subfg.payment.util.ali.AliPayServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PayConfig {
    private Logger log = LoggerFactory.getLogger(PayConfig.class);


    private static SystemPaymentModel systemPaymentModel ;

    @Autowired
    private PaymentServer paymentServer;

    @Autowired
    private AliPayServer aliPayServer;

    @Bean
    public void initConfigPayInfo() {
        systemPaymentModel = new SystemPaymentModel();
        ConfigPayAliModel configPayAliModel = paymentServer.getPaymentAliInfo();
        if (configPayAliModel == null) {
            systemPaymentModel.setSupportAliPayment(false);
        } else {
            aliPayServer.initAliPayInfo(configPayAliModel);
            systemPaymentModel.setSupportAliPayment(true);
        }
    }
}
